<?php

namespace app\admin\controller;

use think\Db;

class Appearance extends Base
{

    /**
     * 添加形象
     */
    public function addAppearance()
    {
        $data = [];
        input('appearance') ? $data['appearance'] = input('appearance') : $this->err('缺少形象！');
        $data['createTime'] = createTime();

        $res = model('appearance')->editData($data);
        $res ? $this->suc($res) : $this->err('添加形象失败！');
    }

    /**
     * 修改形象
     */
    public function editAppearance()
    {
        $data = [];
        input('id') ? $data['id'] = input('id') : $this->err('缺少形象主键！');
        input('appearance') ? $data['appearance'] = input('appearance') : $this->err('缺少形象！');

        $res = model('appearance')->editData($data, $data['id']);
        $res ? $this->suc($res) : $this->err('修改形象失败！');
    }

    /**
     * 查询形象详情
     */
    public function getAppearanceDetail()
    {
        $where = [];
        input('id') ? $where['id'] = input('id') : $this->err('缺少形象主键！');

        $res = model('appearance')->where($where)->find();
        $res ? $this->suc($res) : $this->err('查询失败');
    }

    /**
     * 删除形象
     */
    public function delAppearance()
    {
        $where = [];
        input('id') ? $where['id'] = input('id') : $this->err('缺少形象主键！');

        $res = model('appearance')->where($where)->delete();
        $res ? $this->suc($res) : $this->err('删除形象失败！');

    }

    /**
     * 查询形象列表
     */
    public function getAppearanceList()
    {
        $where = [];
        input('appearance') ? $where['appearance']=['like','%'.input('appearance').'%'] : true;

        $res = model('appearance')->getListByPage($where, 10);
        $res ? $this->suc($res) : $this->err('查询失败！');

    }

}
